<?php
namespace App\Admin\Controllers\Traits\WxSettingTraits;

use App\Jobs\System\SettingImgToJpgJob;
use App\Wen\Utils\AdminUtils;
use App\Wen\Utils\FieldUtils;
use App\Wen\Utils\GatewayUtils;
use App\Wen\Utils\Settings;
use App\Models\Posts\WxPost;
use App\Wen\Utils\SiteUtils;
use Dcat\Admin\Form\NestedForm;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Form;
use Dcat\Admin\Widgets\Tooltip;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;

trait formTrait{

    protected $audit_options = [
        0 => '人工审核',
        1 => '不审',
        2 => 'AI先审，若疑似，则人工'
    ];

    public function index(Content $content)
    {
        return $content->title('全局配置')
//            ->body($this->buildPreviewButton())
//            ->body($this->newline())
            ->body(
                <<<HTML
<div class="card">{$this->form()->render()}</div>
HTML
            );
    }
    protected function form()
    {
        // Since v1.6.5 弹出确认弹窗

        $form = new Form();
        $form->confirm('您确定要提交表单吗？', 'content');
        $form->disableResetButton();

        $form->tab('开关', function (Form $form) {
            $is_multi_site = Settings::get('is_multi_site', 0);
            if(env('APP_IS_MULTI_SITE', 0) != $is_multi_site){
                _update_env([
                    'APP_IS_MULTI_SITE' => $is_multi_site,
                ], [], 1);
            }
            $form->radio('is_multi_site', '多应用模式')->help('开启之后，则会强制选取分站（每次更改左上角可以立即生效，但还有部分需要重新下载前端代码才能生效）')->options([ 0=>'关闭', 1=>'主站+分站', 2=>'主站+分站+测试', 3=>'分站'])->default($is_multi_site)->when('!=',0, function (Form $form){
                $form->text('multi_site_name', '分站统称')->help('每次更改，需要重新下载前端上线生效')->default(Settings::get('multi_site_name', '学校'));
            });
            $form->html(function () {
                return '';
            }, '<b>一、审核开关</b>');
            $form->radio('is_image_detection', '图片安全检测(暂时免费)')->help('<span style="color: red;">需要上线了小程序</span>，并在<a href="'.admin_url('settings/pay').'" target="_blank">[支付_微信]</a>配置好小程序appid和secret')->options([ 1=>'是', 0=>'否'])->default(Settings::get('is_image_detection', 0));
            $form->divider();
            $form->radio('is_audit_posts', '笔记是否需要审核')->help('AI审核需要配置百度文字审核API，<a href="'.admin_url('settings/api').'" target="_blank">点击进入</a>')->options($this->audit_options)->default(Settings::get('is_audit_posts', 0))->when('!=',1, function (Form $form){
                $form->checkbox('audit_posts_white_list', '笔记审核白名单')->options(FieldUtils::userPermissions())->default(Settings::get('audit_posts_white_list', ''));
            });
            $form->divider();

            $form->radio('is_audit_comment', '评论是否需要审核')->help('AI审核需要配置百度文字审核API，<a href="'.admin_url('settings/api').'" target="_blank">点击进入</a>')->options($this->audit_options)->default(Settings::get('is_audit_comment', 0))->when('!=',1, function (Form $form){
                $form->checkbox('audit_comment_white_list', '评论审核白名单')->options(FieldUtils::userPermissions())->default(Settings::get('audit_comment_white_list', ''));
            });
            $form->divider();
            $form->radio('is_audit_user_info', '用户修改资料是否需要审核')->help('AI审核需要配置百度文字审核API，<a href="'.admin_url('settings/api').'" target="_blank">点击进入</a>')->options($this->audit_options)->default(Settings::get('is_audit_user_info', 0));
            $form->radio('is_audit_create_cirlce', '新增'.env('circle_call', '圈子').'审核模式')->help('AI审核需要配置百度文字审核API，<a href="'.admin_url('settings/api').'" target="_blank">点击进入</a>')->options($this->audit_options)->default(Settings::get('is_audit_create_cirlce', 0));
            $form->radio('is_audit_create_tag', '新增话题是否需要审核')->help('AI审核需要配置百度文字审核API，<a href="'.admin_url('settings/api').'" target="_blank">点击进入</a>')->options($this->audit_options)->default(Settings::get('is_audit_create_tag', 0));


            $form->divider();
            $form->html(function () {
                return '';
            }, '<b>二、运营相关</b>');
            $form->radio('is_tag_match_img', '话题自动匹配头像和背景')->options([0=>'关闭', 1=>'开启'])->help('开启后，你访问了一个没有头像或者背景的话题，会自动给他匹配头像或背景')->default(Settings::get('is_tag_match_img', 1));

            $form->divider();

            $version_arr = [
                'all' => '所有版本'
            ];
            $download_front_versions = get_site_meta('my_download_front_versions', 'j');
            foreach ($download_front_versions as $front_version){
                $version_arr[$front_version] = 'V'.$front_version.' +';
            }

            if(env('APP_URL', '') == 'https://mini.minisns.cn'){
                $version_arr[get_mini_version_code()] = get_mini_version_code();
            }

            $form->html(function () {
                return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">上线审核模式？：为了上线时安全的过审，开启审核模式后<span style="font-weight: 600;">不会显示[视频，举报页面的联系方式，提现，充电]等功能<span/></div>';
            }, '');
            $form->html(function () {
                return '<div>---------------------------------------------------------------------------------</div>';
            }, '<b>小程序</b>');
            $form->radio('is_examine_mode', '审核模式')->options([0=>'否', 1=>'是'])->default(Settings::get('is_examine_mode', 0))->when(1, function (Form $form) use (&$version_arr){
                $form->checkbox('app_examine_mode_white_list', '白名单')->options(FieldUtils::userPermissions())->default(Settings::get('app_examine_mode_white_list', ''));
                $form->select('app_examine_mode_effective_version', '作用版本')->options($version_arr)->default(Settings::get('app_examine_mode_effective_version', 'all'));
            });

            $form->html(function () {
                return '<div>---------------------------------------------------------------------------------</div>';
            }, '<b>H5</b>');
            $form->radio('is_h5_examine_mode', '审核模式')->options([0=>'否', 1=>'是'])->default(Settings::get('is_h5_examine_mode', 0))->when(1, function (Form $form) use (&$version_arr){
                $form->checkbox('app_h5_examine_mode_white_list', '白名单')->options(FieldUtils::userPermissions())->default(Settings::get('app_h5_examine_mode_white_list', ''));
                $form->select('app_h5_examine_mode_effective_version', '作用版本')->options($version_arr)->default(Settings::get('app_h5_examine_mode_effective_version', 'all'));
            });

            $form->html(function () {
                return '<div>---------------------------------------------------------------------------------</div>';
            }, '<b>安卓 APP</b>');
            $form->radio('is_app_android_examine_mode', '审核模式')->options([0=>'否', 1=>'是'])->default(Settings::get('is_app_android_examine_mode', 0))->when(1, function (Form $form) use (&$version_arr){
                $form->checkbox('app_app_android_examine_mode_white_list', '白名单')->options(FieldUtils::userPermissions())->default(Settings::get('app_app_android_examine_mode_white_list', ''));
                $form->select('app_app_android_examine_mode_effective_version', '作用版本')->options($version_arr)->default(Settings::get('app_app_android_examine_mode_effective_version', 'all'));
            });

            $form->html(function () {
                return '<div>---------------------------------------------------------------------------------</div>';
            }, '<b>IOS APP</b>');
            $form->radio('is_app_ios_examine_mode', '审核模式')->options([0=>'否', 1=>'是'])->default(Settings::get('is_app_ios_examine_mode', 0))->when(1, function (Form $form) use (&$version_arr){
                $form->checkbox('app_app_ios_examine_mode_white_list', '白名单')->options(FieldUtils::userPermissions())->default(Settings::get('app_app_ios_examine_mode_white_list', ''));
                $form->select('app_app_ios_examine_mode_effective_version', '作用版本')->options($version_arr)->default(Settings::get('app_app_ios_examine_mode_effective_version', 'all'));
            });

        });

        $form->tab('关于', function (Form $form) {
            $form->text('app_title', '品牌名')->default(Settings::get('app_title', '宠也'));
            $form->text('app_intro', '简介')->default(Settings::get('app_intro', '养宠上宠也'));
            $form->image('about_logo', '图标')->help('<a href="https://img.mini.minisns.cn/icons/logo.png" download="about_logo.jpg" target="_blank">点击下载默认图</a>')->url('files/uploads')->autoUpload()->uniqueName()->default(Settings::get('about_logo', 'https://img.mini.minisns.cn/icons/logo.pn'));
            $form->text('about_title', '标识语')->default(Settings::get('about_title', '宠也，养宠上宠也'));
            $form->text('about_adjunct_word', '行业修饰词')->help('关于这个在一些特殊的场合会用到，比如自动上传话题的头像，是利用搜索关键词，比如：疫苗，如果配置了修饰词“宠物”，则搜索“疫苗 宠物”，会相对接近自己的领域，不宜太长，否则适得其反，自己领悟')->default(Settings::get('about_adjunct_word', ''));
            $form->text('about_user_called', '用户统称')->default(Settings::get('about_user_called', '铲屎官'));
            $form->text('about_copyright', '版权')->default(Settings::get('about_copyright', 'Copyright © 2020 - 现在，东莞市东城友看网络科技有限公司'));
            $form->text('about_icp', 'icp备案号')->default(Settings::get('about_icp', '粤ICP备2022011211号-1'));
            $form->text('about_gwab', '公网安备')->default(Settings::get('about_gwab', '京公网安备11010802020088号'));
            $form->text('about_sms', '邮箱')->default(Settings::get('about_sms', '863627472@qq.com'));
            $form->text('about_address', '地址')->default(Settings::get('about_address', '东莞市东城区xxx'));
            $form->text('about_phone', '电话')->default(Settings::get('about_phone', '176-xxxx-8804（同微信）'));
            $form->text('about_qq', 'QQ')->default(Settings::get('about_qq', '863627472'));
            $form->table('app_document_list','证件', function (NestedForm $table) {
                $table->text('name', '证件名')->required()->placeholder('增值电信许可证');
                $table->image('img', '图片')->uniqueName()->url('files/uploads')->autoUpload();
            })->default(Settings::get('app_document_list', ''));
        });
        $form->tab('二维码', function (Form $form) {
            $form->image('app_mini_code', '小程序二维码')->help('建议和默认图片大小。 <a href="https://img.minisns.cn/qrcode/minipro.jpg" download="app_login_bg.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('app_mini_code', 'https://img.minisns.cn/qrcode/minipro.jpg'));
            $form->image('app_mp_code', '公众号二维码')->help('建议和默认图片大小。 <a href="https://img.minisns.cn/pc/gzh_code.jpg" download="app_login_bg.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('app_mp_code', 'https://img.minisns.cn/pc/gzh_code.jpg'));
            $form->image('app_app_code', 'App二维码')->help('建议和默认图片大小。 <a href="https://img.minisns.cn/qrcode/app.png" download="app_login_bg.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('app_app_code', 'https://img.minisns.cn/qrcode/app.png'));
            $form->image('app_douyin_code', '抖音二维码')->help('建议和默认图片大小。 <a href="https://img.minisns.cn/qrcode/app.png" download="app_login_bg.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('app_douyin_code', 'https://img.minisns.cn/qrcode/app.png'));
        });

        $form->tab('标识', function (Form $form) {
            $form->image('official_popup_poster', '官方弹窗海报')->help('建议图片大小为500px。 <a href="https://img.mini.minisns.cn/images/guanfangpopup.png" download="official_popup_poster.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('official_popup_poster', 'https://img.mini.minisns.cn/images/guanfangpopup.png'));
            $form->image('authentication_popup_poster', '认证弹窗海报')->help('<a href="https://img.mini.minisns.cn/icons/auth.png" download="authentication_popup_poster.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('authentication_popup_poster', 'https://img.mini.minisns.cn/icons/auth.png'));
            $form->image('popup_reward_select_img', '充电弹窗图片')->help('<a href="https://img.mini.minisns.cn/icons/rain.png" download="authentication_popup_poster.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('popup_reward_select_img', 'https://img.mini.minisns.cn/icons/rain.png'));
            $form->image('popup_beliked_count_img', '被喜欢数弹窗图片')->help('<a href="https://img.mini.minisns.cn/icons/collect-likes.png" download="authentication_popup_poster.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('popup_beliked_count_img', 'https://img.mini.minisns.cn/icons/collect-likes.png'));
        });
        $form->tab('浏览器', function (Form $form) {
            $form->image('browser_favicon_ico', 'favicon')->help('<a href="https://img.mini.minisns.cn/icons/favicon.ico" download="members_popup_poster.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('browser_favicon_ico', 'https://img.mini.minisns.cn/icons/favicon.ico'));
        });

        $form->tab('图片', function (Form $form) {
            $form->image('img_empty', '空')->help('<a href="https://img.mini.minisns.cn/icons/abp.png" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('img_empty', 'https://img.mini.minisns.cn/icons/abp.png'));
            $form->image('img_default', '默认图片')->help('<a href="https://img.mini.minisns.cn/icons/dafault.png" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('img_default', 'https://img.mini.minisns.cn/icons/dafault.png'));
            $form->image('img_share_default', '默认分享图片')->help('<a href="https://img.mini.minisns.cn/2023/05/22/17f31da7ce65a148b7c879c066f56f71.png" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('img_share_default', 'https://img.mini.minisns.cn/2023/05/22/17f31da7ce65a148b7c879c066f56f71.png'));
            $form->image('img_post_poster_default', '笔记默认海报图')->help('<a href="https://img.mini.minisns.cn/images/hbx/post_poster.png" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('img_post_poster_default', 'https://img.mini.minisns.cn/images/hbx/post_poster.png'));
            $form->image('img_video_default', '视频封面')->help('<a href="https://img.mini.minisns.cn/images/video/video_thumbel.png" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>，App上传的视频获取不到封面，后面使用cos处理')->url('files/uploads')->uniqueName()->autoUpload()->default(Settings::get('img_video_default', 'https://img.mini.minisns.cn/images/video/video_thumbel.png'));
            $form->image('img_default_avatar', '默认头像')->help('建议和默认图片大小。 <a href="https://img.mini.minisns.cn/images/avatar.png" download="img_default_avatar.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('img_default_avatar', 'https://img.mini.minisns.cn/images/avatar.png'));
            $form->image('img_default_circle_bg', env('circle_call', '圈子').'背景')->help('默认的话题移动端背景：<a href="https://img.mini.minisns.cn/images/topci/bg.jpg" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('img_default_circle_bg', 'https://img.mini.minisns.cn/images/topci/bg.jpg'));
            $form->image('img_default_topic_avatar', '话题头像')->help('默认的话题头像：<a href="https://img.mini.minisns.cn/images/topci/avatar.png" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('img_default_topic_avatar', 'https://img.mini.minisns.cn/images/topci/avatar.png'));
            $form->image('img_default_topic_bg', '话题背景')->help('默认的话题移动端背景：<a href="https://img.mini.minisns.cn/images/topci/bg.jpg" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('img_default_topic_bg', 'https://img.mini.minisns.cn/images/topci/bg.jpg'));
            $form->image('img_default_topic_pc_bg', '话题pc背景')->help('默认的话题pc端背景：<a href="https://img.mini.minisns.cn/images/topci/bg.jpg" download="dafault.jpg" target="_blank" style="color: steelblue">点击下载默认图</a>')->uniqueName()->url('files/uploads')->autoUpload()->default(Settings::get('img_default_topic_pc_bg', 'https://img.mini.minisns.cn/images/topci/bg.jpg'));

            $form->radio('img_style_action', '图片加速方案')->options([0=>'不处理（加载慢）', 1=>'系统处理（官网）', 2=>'手动配置（自定义）'])->when(2, function (Form $form){
                $form->html(function () {
                    return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">简单说明一下：<br>1、样式用英文逗号隔开，比如：样式一,样式二,样式三,样式四<br>2、样式一: 列表图片；样式二: 瀑布流样式；样式三：小方格；样式四：未定；<br>3、官方配置<span style="color: red;">【强烈推荐】</span>：<a href="https://img.mini.minisns.cn/images/style_4.txt" download="style_4.txt">点击下载</a>，下载后可直接导入，<a href="https://doc.minisns.cn/doc/62/" target="_blank">具体看教程</a>，然后配置填写：/20220303500.jpg,/waterfall,/grid,/xxx</div>';
                }, '');
                $form->table('img_style','图片样式', function (NestedForm $table) {
                    $table->text('domain', '域名')->default('https://img.minisns.cn');
                    $table->text('style', '样式')->default('样式1,样式2,样式3,样式4');
                })->default(Settings::get('img_style', ''));
            })->default(Settings::get('img_style_action', 1));

        });

        $form->tab('举报', function (Form $form) {
            $form->html(function () {
                return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">被举报安全次数：每个普通用户对某个对象只能举报一次，当某个对象被举报总次数超过了安全次数，该对象被自动下架（对象包括：内容，评论，用户，商品等），如果举报人是管理员，则会立即响应。</div>';
            }, '');
            $form->number('app_report_safe_times_post', '内容-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_post', 0));
            $form->number('app_report_safe_times_comment', '评论-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_comment', 0));
            $form->number('app_report_safe_times_user', '用户-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_user', 0));
            $form->number('app_report_safe_times_goods', '商品-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_goods', 0));
            $form->number('app_report_safe_times_circle', env('circle_call', '圈子').'-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_circle', 0));
            $form->divider();
            $form->number('app_report_safe_times_bureau', '组局-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_bureau', 0));
            $form->number('app_report_safe_times_voter', '选票-被举报安全次数')->help('0代表无限制')->default(Settings::get('app_report_safe_times_voter', 0));
        });

        $form->tab('H5端', function (Form $form) {
            $form->text('app_h5_home', 'H5端域名')->help('H5端是你生成H5静态代码后，部署到服务器，什么域名能访问到。例如：https://mini.h5.minisns.cn')->placeholder('https://mini.h5.minisns.cn')->default(Settings::get('app_h5_home', ''));
        });

        $form->action('settings/wx');
        return $form;
    }

    public function wx(Request $request)
    {
        SiteUtils::forget_config_data();

        $is_multi_site = $request->input('is_multi_site');
        if(!in_array($is_multi_site, [0, 1, 2, 3])){
            $is_multi_site = 0;
        }

        _update_env([
            'APP_IS_MULTI_SITE' => $is_multi_site,
            'MINI_EXAMINE_VER' => $request->input('app_examine_mode_effective_version', ''),
            'H5_EXAMINE_VER' => $request->input('app_h5_examine_mode_effective_version', ''),
            'ANDROID_EXAMINE_VER' => $request->input('app_app_android_examine_mode_effective_version', ''),
            'IOS_EXAMINE_VER' => $request->input('app_app_ios_examine_mode_effective_version', ''),
        ], [], 1);

        Settings::set('is_image_detection', $request->input('is_image_detection'), true);
        Settings::set('is_multi_site', $is_multi_site, true);
        Settings::set('multi_site_name', $request->input('multi_site_name'), true);
        Settings::set('is_audit_posts', $request->input('is_audit_posts'), true);
        Settings::set('is_audit_comment', $request->input('is_audit_comment'), true);
        Settings::set('is_audit_user_info', $request->input('is_audit_user_info'), true);
        Settings::set('is_audit_create_cirlce', $request->input('is_audit_create_cirlce'), true);
        Settings::set('is_audit_create_tag', $request->input('is_audit_create_tag'), true);
        Settings::set('is_tag_match_img', $request->input('is_tag_match_img'), true);


        $audit_posts_white_list = $request->input('audit_posts_white_list');
        $audit_posts_white_list_ = [];
        if($audit_posts_white_list){
            foreach ($audit_posts_white_list as $i){
                if($i === null){
                    continue;
                }
                $audit_posts_white_list_[] = (int)$i;
            }
        }

        $audit_comment_white_list = $request->input('audit_comment_white_list');
        $audit_comment_white_list_ = [];
        if($audit_comment_white_list){
            foreach ($audit_comment_white_list as $i){
                if($i === null){
                    continue;
                }
                $audit_comment_white_list_[] = (int)$i;
            }
        }

        $app_examine_mode_white_list = $request->input('app_examine_mode_white_list');
        $app_examine_mode_white_list_ = [];
        if($app_examine_mode_white_list){
            foreach ($app_examine_mode_white_list as $i){
                if($i === null){
                    continue;
                }
                $app_examine_mode_white_list_[] = (int)$i;
            }
        }


        $app_h5_examine_mode_white_list = $request->input('app_h5_examine_mode_white_list');
        $app_h5_examine_mode_white_list_ = [];
        if($app_h5_examine_mode_white_list){
            foreach ($app_h5_examine_mode_white_list as $i){
                if($i === null){
                    continue;
                }
                $app_h5_examine_mode_white_list_[] = (int)$i;
            }
        }


        $app_app_android_examine_mode_white_list = $request->input('app_app_android_examine_mode_white_list');
        $app_app_android_examine_mode_white_list_ = [];
        if($app_app_android_examine_mode_white_list){
            foreach ($app_app_android_examine_mode_white_list as $i){
                if($i === null){
                    continue;
                }
                $app_app_android_examine_mode_white_list_[] = (int)$i;
            }
        }


        $app_app_ios_examine_mode_white_list = $request->input('app_app_ios_examine_mode_white_list');
        $app_app_ios_examine_mode_white_list_ = [];
        if($app_app_ios_examine_mode_white_list){
            foreach ($app_app_ios_examine_mode_white_list as $i){
                if($i === null){
                    continue;
                }
                $app_app_ios_examine_mode_white_list_[] = (int)$i;
            }
        }



        Settings::set('audit_posts_white_list', $audit_posts_white_list_, true);
        Settings::set('audit_comment_white_list', $audit_comment_white_list_, true);
        Settings::set('app_examine_mode_white_list', $app_examine_mode_white_list_, true);

        Settings::set('app_examine_mode_effective_version', $request->input('app_examine_mode_effective_version'), true);
        Settings::set('app_h5_examine_mode_effective_version', $request->input('app_h5_examine_mode_effective_version'), true);
        Settings::set('app_app_android_examine_mode_effective_version', $request->input('app_app_android_examine_mode_effective_version'), true);
        Settings::set('app_app_ios_examine_mode_effective_version', $request->input('app_app_ios_examine_mode_effective_version'), true);



        Settings::set('app_h5_examine_mode_white_list', $app_h5_examine_mode_white_list_, true);
        Settings::set('app_app_android_examine_mode_white_list', $app_app_android_examine_mode_white_list_, true);
        Settings::set('app_app_ios_examine_mode_white_list', $app_app_ios_examine_mode_white_list_, true);

        Settings::set('is_examine_mode', $request->input('is_examine_mode'), true);
        Settings::set('is_h5_examine_mode', $request->input('is_h5_examine_mode'), true);
        Settings::set('is_app_android_examine_mode', $request->input('is_app_android_examine_mode'), true);
        Settings::set('is_app_ios_examine_mode', $request->input('is_app_ios_examine_mode'), true);

        // 二维码
        Settings::set('app_mini_code', $request->input('app_mini_code'), true);
        Settings::set('app_mp_code', $request->input('app_mp_code'), true);
        Settings::set('app_app_code', $request->input('app_app_code'), true);
        Settings::set('app_douyin_code', $request->input('app_douyin_code'), true);

        // 关于
        Settings::set('app_title', $request->input('app_title'), true);
        Settings::set('app_intro', $request->input('app_intro'), true);
        Settings::set('about_logo', $request->input('about_logo'), true);
        Settings::set('about_title', $request->input('about_title'), true);
        Settings::set('about_copyright', $request->input('about_copyright'), true);

        Settings::set('about_icp', $request->input('about_icp'), true);
        Settings::set('about_gwab', $request->input('about_gwab'), true);
        Settings::set('about_sms', $request->input('about_sms'), true);
        Settings::set('about_address', $request->input('about_address'), true);
        Settings::set('about_phone', $request->input('about_phone'), true);
        Settings::set('about_qq', $request->input('about_qq'), true);
        Settings::set('about_adjunct_word', $request->input('about_adjunct_word'), true);
        Settings::set('about_user_called', $request->input('about_user_called'), true);
        Settings::set('app_document_list', AdminUtils::_table_data($request->input('app_document_list')), true);


        // 标识
        Settings::set('authentication_popup_poster', $request->input('authentication_popup_poster'), true);
        Settings::set('official_popup_poster', $request->input('official_popup_poster'), true);
        Settings::set('popup_reward_select_img', $request->input('popup_reward_select_img'), true);
        Settings::set('popup_beliked_count_img', $request->input('popup_beliked_count_img'), true);

        // 图片
        Settings::set('img_empty', $request->input('img_empty'), true);
        Settings::set('img_default', $request->input('img_default'), true);
        Settings::set('img_share_default', $request->input('img_share_default'), true);
        Settings::set('img_post_poster_default', $request->input('img_post_poster_default'), true);
        Settings::set('img_sounds_default', $request->input('img_sounds_default'), true);
        Settings::set('img_video_default', $request->input('img_video_default'), true);
        Settings::set('img_default_circle_bg', $request->input('img_default_circle_bg'), true);
        Settings::set('img_default_avatar', $request->input('img_default_avatar'), true);
        Settings::set('img_default_topic_avatar', $request->input('img_default_topic_avatar'), true);
        Settings::set('img_default_topic_bg', $request->input('img_default_topic_bg'), true);
        Settings::set('img_default_topic_pc_bg', $request->input('img_default_topic_pc_bg'), true);

        // 举报
        Settings::set('app_report_safe_times_post', $request->input('app_report_safe_times_post'), true);
        Settings::set('app_report_safe_times_comment', $request->input('app_report_safe_times_comment'), true);
        Settings::set('app_report_safe_times_user', $request->input('app_report_safe_times_user'), true);
        Settings::set('app_report_safe_times_goods', $request->input('app_report_safe_times_goods'), true);
        Settings::set('app_report_safe_times_circle', $request->input('app_report_safe_times_circle'), true);
        Settings::set('app_report_safe_times_bureau', $request->input('app_report_safe_times_bureau'), true);
        Settings::set('app_report_safe_times_voter', $request->input('app_report_safe_times_voter'), true);


        Cache::forget('img_all_style_names');
        $img_style_str = AdminUtils::_table_data($request->input('img_style'));
        $img_style_arr = json_decode($img_style_str, true);
        if($img_style_arr){
            $style_ = [];
            foreach ($img_style_arr as $img_style){
                $style_ = array_merge($style_, explode(',', $img_style['style']));
            }
            Cache::put('img_all_style_names', json_encode(array_unique($style_)));
        }
        Settings::set('img_style', $img_style_str, true);
        Settings::set('img_style_action', $request->input('img_style_action'), true);



        // 浏览器
        Settings::set('browser_favicon_ico', $request->input('browser_favicon_ico'), true);

        // H5
        Settings::set('app_h5_home', rtrim($request->input('app_h5_home') ?? '', '/'), true);

        SettingImgToJpgJob::dispatch(['img_share_default']);

        $__global_config_version__ = Settings::get('__global_config_version__', 1) + 1;
        Settings::set('__global_config_version__', $__global_config_version__);
        GatewayUtils::success('all', 13, [ 'version' => $__global_config_version__, 'file' => basename(__FILE__) ]);
        return $this->response()->success('成功！');
    }

}
